<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/js/jquery.min.js" type="text/javascript"></script>

    <style>
        /*<!--        设置div位置->*/
        #HuoZhuDiv{
            position: absolute;
        }

        .icon:after{
            content: '* ';
            color: red;
        }
    </style>
    <script>
        function checktime() {
            var zdata = new Date(document.getElementById("billDate").value.replace("//-/g", "//"));
            var wdata = new Date(document.getElementById("billEditTime").value.replace("//-/g", "//"));
            if(wdata<zdata){
                alert("结算日期不能小于开始日期")
            }else {
                alert("日期格式正确")
            }
        }
        function lastpage(page) {
            var dingweiId = $("#dingweiId").val();
            var billDate = $("#billDate").val();
            var billEditTime = $("#billEditTime").val();
            var huozhuName = $("#huozhuName").val();
            var rukudanhao = $("#rukudanhao").val();
            var pagerows = $("#pageRows").val();
            window.location = "hwrkuSelectData.do?newpageNum="+page+"&pageRows="+pagerows+"&billDate="+billDate+"&billEditTime="+billEditTime+"&huozhuName="+huozhuName+"&rukudanhao="+rukudanhao+"&dingweiId="+dingweiId;
        }
        function lastpage1(row) {
            var billDate = $("#billDate").val();
            var billEditTime = $("#billEditTime").val();
            var huozhuName = $("#huozhuName").val();
            var rukudanhao = $("#rukudanhao").val();
            var pageNum = $("#pageNum").val();
            var dingweiId = $("#dingweiId").val();
            window.location = "hwrkuSelectData.do?newpageNum="+pageNum+"&pageRows="+row+"&huozhuName="+huozhuName+"&rukudanhao="+rukudanhao+"&billDate="+billDate+"&billEditTime="+billEditTime+"&dingweiId="+dingweiId;
        }
    </script>
</head>
<body>

<form action="hwrkuSelectData.do">
    <input type="hidden" value="2" name="dingweiId" id="dingweiId">
    <h3><font color="blue">入库管理>>></font><font color="blue">入库单查询</font></h3>
    <h4><font color="blue">查询</font></h4>
    <table border="1" style="border: skyblue" width="1200px">
        <tr><td>入库时间</td><td colspan="5"><input type="text" placeholder="yyyy-MM-dd" id="billDate" name="billDate">/<input type="text" placeholder="yyyy-MM-dd"  id="billEditTime" name="billEditTime" onblur="checktime()"></td></tr>
        <tr><td>入库单号</td><td colspan="5"><input type="text"  id="rukudanhao" name="rukudanhao"></td></tr>
        <tr><td>货主名</td><td colspan="5"><input type="text"  id="huozhuName" name="huozhuName" ></td></tr>
        <tr><td></td><td colspan="5"><button id="check">查询</button></td></tr>
        <tr>
            <td rowspan="3" colspan="6">每页显示条数:
                <select name="pageRows" id="pageRows" onchange="lastpage1(this.value)">
                    <option th:each="i:${session.list}" th:text="${i}" th:value="${i}" th:selected="${session.pageRows == i}"></option>
                </select>
                第<label th:text="${session.pageInfo.getPageNum()}"></label>页
                <input type="hidden" th:value="${session.pageInfo.getPageNum()}" id="pageNum">
            </td>
        </tr>
        <tr></tr><tr></tr>
        <!--        <tr><td><input type="text"></td><td><input type="text"></td><td><input type="text"></td><td><input type="text"></td><td><input type="text"></td><td><input type="text"></td></tr>-->


    </table>
</form>

<label th:if="${session.pageInfo.size==0}" style="color: #ff4400">没有查到任何数据!请核对查询信息</label>
<table id="table2" th:if="${session.pageInfo.size!=0}" border="1" style="border: skyblue" width="1200px">
    <tr><td>入库单单号</td><td>结算员</td><td>货主</td><td>业务时间</td><td>应收款</td><td>实际收款</td><td>力资费</td><td>其他费用</td><td>入库单状态</td><td>是否删除</td></tr>
    <tr th:each="everyBillDetails:${session.pageInfo.getList()}">
        <td><input type="radio" name="eveBillsRuKuDanId" th:value="${everyBillDetails.billId}" id="eveBillsRuKuDanId" onclick="huoQuShuJu(this.value)"><span th:text="${everyBillDetails.billId}"></span></td>
        <td th:text="${everyBillDetails.billTransactor}"></td>
        <td th:text="${everyBillDetails.custName}"></td>
        <td th:text="${everyBillDetails.billDate}"></td>
        <td th:text="${everyBillDetails.billPayable}"></td>

        <td th:text="${everyBillDetails.billPaid}"></td>
        <td th:text="${everyBillDetails.billFeeTruckage}"></td>
        <td th:text="${everyBillDetails.billFeeOther}"></td>
        <td th:text="${everyBillDetails.billState}"></td>
        <td th:text="${everyBillDetails.billIsDel}"></td>

    </tr>
    <tr><button th:value="${session.pageInfo.getPageNum()>1?session.pageInfo.getPageNum()-1:session.pageInfo.getPageNum()}" onclick="lastpage(this.value)">上一页</button>
        <button th:value="${session.pageInfo.getPageNum()<session.pageInfo.getSize()?session.pageInfo.getPageNum()+1:session.pageInfo.getPageNum()}" onclick="lastpage(this.value)">下一页</button></tr>
</table>
<h4><font color="blue">入库单信息</font></h4>
<table border="1" style="border: skyblue" width="1200px">
    <tr>
        <td colspan="1" >入库单单号:</td><td colspan="5" class="icon"><input type="text" id="ruhuodandanhao" disabled="disabled"><input type="hidden" id="rukudanhao1"></td>
    </tr>
    <tr>
        <td colspan="1">货主:</td><td colspan="5"><input type="text" id="huozhuming"></td>
    </tr>
    <tr>
        <td style="width: 150px">力资费:</td><td colspan="5"><input type="text" id="lizifei"></td>
    </tr>
    <tr>
        <td style="width: 150px">业务时间:</td><td colspan="5"><input type="text" id="yewushijian"></td>
    </tr>
    <tr>
        <td style="width: 150px">最后编辑时间:</td><td colspan="5"><input type="text" id="zuihoubianjishijian"></td>
    </tr>
    <tr>
        <td style="width: 150px">单据状态:</td><td colspan="5"><input type="text" id="danjuzhuangtai"></td>
    </tr>
    <tr>
        <td style="width: 150px">备注:</td>
        <td class="ta_01" bgColor="#ffffff" colspan="5">
        <textarea name="pdesc" rows="5" cols="50"></textarea>
        </td>
    </tr>
    <tr>
        <td style="width: 150px">是否删除:</td><td colspan="5">
        <input type="radio" name="shanchu"  id="shanchu" value="1"><span th:text="删除"></span>
        <input type="radio" name="shanchu"  id="xiugai" value="2"><span th:text="修改"></span>
    </td>
    </tr>
    <tr>
        <td></td><td colspan="5"><input type="submit" value="提交" onclick="shanCuxiuGai()"></td>
    </tr>
</table>


</form>
</body>

<script type="text/javascript">
    function shanCuxiuGai() {
        var loves = document.getElementsByName("shanchu");
        for (var i = 0; i < loves.length; i++) {
            if (loves[i].checked == true){



                var rukudanhao1 = $("#rukudanhao1").val();




                if(rukudanhao1==null ||rukudanhao1==""){
                    alert("请选择要操作的入库单单号！")
                   loves[i].removeAttribute("checked");
                }else{
                    var value1 =  loves[i].value;
                    var lizifei1 = $("#lizifei").val();
                    var yewushijian1 = $("#yewushijian").val();
                    var zuihoubianjishijian1 = $("#zuihoubianjishijian").val();
                    var danjuzhuangtai1 = $("#danjuzhuangtai").val();
                    $.ajax({
                        type:"post",
                        url:"/updateRuKuDanChaXun.do?rukudanhao1="+rukudanhao1+"&lizifei1="+lizifei1+ "&yewushijian1="+yewushijian1+"&zuihoubianjishijian1="+zuihoubianjishijian1+"&danjuzhuangtai1="+danjuzhuangtai1+"&value1="+value1,
                        success:function (data) {
                            if(data==true){
                                alert("删除成功！")
                            }else{
                                alert("修改成功！")
                            }
                        }

                    })
                }

            }

        }

    }

    function huoQuShuJu(eveBillsRuKuDanId) {
        var  eveId66 = document.getElementsByName("eveBillsRuKuDanId")
        for (let i = 0; i < eveId66.length; i++) {
            if (eveId66[i].checked==true){
                // alert(eveBillsRuKuDanId);
                $.ajax({
                    type:"post",
                    url:"/selectBillsByHeId.do?eveBillsRuKuDanId="+eveBillsRuKuDanId,
                    success:function (data) {
                        $("#ruhuodandanhao").val(data.billId)
                        $("#rukudanhao1").val(data.billId)
                        $("#huozhuming").val(data.custName)
                        $("#lizifei").val(data.billFeeTruckage)
                        $("#yewushijian").val(data.billDate)
                        $("#zuihoubianjishijian").val(data.billEditTime)
                        $("#danjuzhuangtai").val(data.billState)
                    }
                })
            }
        }
    }
</script>
</html>